package com.md.common.utils.security;

import com.md.common.utils.json.JSONUtil;

/**
 * 功能描述：加密接口请求参数解密工具
 *
 * @author lujianping@oak168.com
 * @version 1.0
 * @date 2018-08-15 14:57
 * @since JDK 1.8
 */
public class ReqDataDecrypUtil {

    /**
     * RSA加密串解密并转化成指定DTO
     * @param encryptedStr
     * @param targetDtoClass
     * @param <T>
     * @return
     * @throws Exception
     */
    public static <T> T decrypt2Dto(String encryptedStr, Class<T> targetDtoClass) throws Exception{
        String decryptedStr = RSAUtils.decrypttoStr(encryptedStr);
        //JSON2Dto
        T targetDto = JSONUtil.toBean(decryptedStr, targetDtoClass);
        return targetDto;
    }
}
